#region Summary

// 
// Owner : JackieHan 
// 
// Solution : UpdateSystem
// 
// Project :Skomart.Update.Test
// 
// File : TestSerilize.cs
// 
// CopyRight : Copyright © 2010-2011 Skomart Corporation, All Rights Reserved 
// 
// Summary : 测试Xml序列化
// 
// History : 
//			2011-01-07 10:00:39    Create 
// 

#endregion

#region Using

using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using NUnit.Framework;

#endregion

namespace Skomart.Update.Test
{
    /// <summary> 
    /// 测试Xml序列化
    /// </summary>
    [TestFixture]
    public class TestSerilize
    {
        [XmlRoot]
        public class SystemConfig
        {
            [XmlElement]
            public string ShowName { get; set; }
            [XmlElement]
            public string Name { get; set; }
            [XmlElement]
            public string LocalPath { get; set; }
        }

        private List<SystemConfig> systemConfigs;

        [SetUp]
        public void SetUp()
        {
            systemConfigs = new List<SystemConfig>
                                {
                                    new SystemConfig{LocalPath = "aaaa",Name = "aaaa",ShowName = "aaaa"},
                                    new SystemConfig{LocalPath = "aaaa",Name = "aaaa",ShowName = "aaaa"},
                                    new SystemConfig{LocalPath = "aaaa",Name = "aaaa",ShowName = "aaaa"}
                                };
            
        }

        [Test]
        public void Test()
        {
            var path = @"E:\Skomart\Code\UpdateSystem\Skomart.Update.Test\bin\Debug\ConfigFiles\systemConfig.xml";
            using (var stream = new FileStream(path, FileMode.Create))
            {
                var serializer = new XmlSerializer(typeof (List<SystemConfig>));
                using (var writer = XmlDictionaryWriter.CreateTextWriter(stream))
                {
                    serializer.Serialize(writer, systemConfigs);
                }
            }
        }

        [TearDown]
        public void TearDown()
        {
        }
    }
}